<template>
  <div>
    <h1>register</h1>
    <form>
      <input type="text" v-model="name" />
      <br />
      <input type="text" v-model="password" />
      <br />
      <input type="submit" value="注册" @click.prevent="register" />
    </form>
  </div>
</template>

<script>
import ajax from "../api/ajax.js";
export default {
  data() {
    return {
      name: "",
      password: ""
    };
  },
  methods: {
    async register() {
      const url = "/api/register";
      const data = {};
      data.name = this.name;
      data.password = this.password;
      // url, method = "get", data, headType
      const result = await ajax(url, "post", data, "form");
      console.log(result);
    }
  }
};
</script>

<style></style>
